package de.vogella.jface.treeviewer.provider;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import com.rcp.steve.crm.Activator;

import de.vogella.jface.treeviewer.model.Todo;

public class TodoLabelProvider extends LabelProvider {
	@Override
	public String getText(Object element) {
		if (element instanceof Todo) {
			Todo category = (Todo) element;
			return category.getSummary();
		}
		return ((Todo) element).getSummary();
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
		// TODO Auto-generated method stub
		super.addListener(listener);
	}

	@Override
	public Image getImage(Object element) {
		if (element instanceof Todo) {
			Todo todo = (Todo) element;
			if (!todo.isLeaf()) {
				return PlatformUI.getWorkbench().getSharedImages()
						.getImage(ISharedImages.IMG_OBJ_FOLDER);
			}if("analysis".equals(todo.getType())){
				return Activator.getImage("/icons/exe.gif");
			}
			if("current".equals(todo.getType())){
				return Activator.getImage("/icons/image.gif");
			}
		}
		
		return PlatformUI.getWorkbench().getSharedImages()
				.getImage(ISharedImages.IMG_OBJ_FILE);
	}

}